package com.example.lib_log.logger

import android.util.Log
import com.example.lib_log.ILogger
import com.example.lib_log.LoggerLevel

/*
打印在文件中
 */
class FileLogger :ILogger{
    private var isDebug = true
    private var TAG=""
    private var level= LoggerLevel.Debug
    private var loggerFormat="(:=>$TAG %s -->%s"//%s为占位符
    private var url=""
    override fun d(tag: String, log: String) {
        if (isDebug && level.ordinal>= LoggerLevel.Debug.ordinal){
//            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun v(tag: String, log: String) {
        if (isDebug && level.ordinal>= LoggerLevel.Debug.ordinal){
//            Log.v(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if (isDebug && level.ordinal>= LoggerLevel.Debug.ordinal){
//            Log.i(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun w(tag: String, log: String) {
        if (isDebug && level.ordinal>= LoggerLevel.Debug.ordinal){
//            Log.w(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun e(tag: String, log: String) {
        if (isDebug && level.ordinal>= LoggerLevel.Debug.ordinal){
//            Log.e(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug=isDebug
    }

    override fun setLogTAG(TAG: String) {
        this.TAG=TAG
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.level=level
    }

    override fun setSaveUrl(url: String) {
        this.url=url
    }
}